package com.ruoyi.system.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "APP端用户信息")
@RequestMapping("/app/user")
@RestController
public class AppSysUserController extends BaseController {

    @Autowired
    private ISysUserService userService;

    /**
     * 个人信息详情
     */
    @GetMapping
    @ApiOperation(value = "当前用户个人信息详情", response = SysUser.class)
    public AjaxResult userInfo() {
        Long userId = SecurityUtils.getUserId();
        return success(userService.selectUserInfoByUserId(userId));
    }

    /**
     * 根据首字母分组获取用户nickName
     */
    @GetMapping("/userList")
    @ApiOperation(value = "根据首字母分组获取用户nickName", response = SysUser.class)
    public AjaxResult userList(SysUser user) {
       return success(userService.selectSimpleUserList(user));
    }

    /**
     * 根据用户名称获取用户Id
     */
    @GetMapping("/getUserId")
    @ApiOperation(value = "根据用户名称获取用户Id", response = SysUser.class)
    public AjaxResult getUserId(SysUser user) {
        return success(userService.getUserId(user.getNickName()));
    }

}
